﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace Allegro.TaskExecution
{
    /// <summary>
    /// Delegate for execution in context
    /// </summary>
    /// <param name="context"></param>
    public delegate void RunInContext(IExecutionContext context);

    /// <summary>
    /// Delegate for late-bound enumeration in context
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    public delegate IEnumerable EnumerateInContext(IExecutionContext context);

    /// <summary>
    /// Task for running a delegate
    /// </summary>
    public class RunDelegate : Task
    {
        ///<summary>
        ///</summary>
        public new RunInContext Execute;

        /// <summary>
        /// 
        /// </summary>
        public RunDelegate()
        {
            
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="e"></param>
        public RunDelegate(RunInContext e)
        {
            Execute = e;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        protected override void ExecuteTask(IExecutionContext context)
        {
            if(Execute != null)
            {
                Execute(context);
            }
        }
    }
}
